Dart.PowerTCP.SslSockets Namespace > Trace Class > BeginSend Method : BeginSend(String,Byte[],Object) Method |
Asynchronously trace a route to a host, specifying data to send.
[Visual Basic]
<DescriptionAttribute("Begin an asynchronous Ping with a remote host, local host, the data sent, and any object.")>
Overloads Public Function BeginSend( _
ByVal remoteHost As String, _
ByVal data() As Byte, _
ByVal state As Object _
) As IAsyncResult
[C#]
[DescriptionAttribute("Begin an asynchronous Ping with a remote host, local host, the data sent, and any object.")]
public IAsyncResult BeginSend(
string remoteHost,
byte[] data,
object state
);
[C++]
[DescriptionAttribute("Begin an asynchronous Ping with a remote host, local host, the data sent, and any object.")]
public: IAsyncResult* BeginSend(
string* remoteHost,
byte[]* data,
Object* state
)
[C++/CLI]
[DescriptionAttribute("Begin an asynchronous Ping with a remote host, local host, the data sent, and any object.")]
public:
IAsyncResult^ BeginSend(
String^ remoteHost,
bytearray<data>^ data,
Object^ state
)
An IAsyncResult that represents the asynchronous trace operation, which could still be pending.
Exception | Description |
---|---|
InvalidOperationException | BeginXXX method used without providing an EndXXX event handler. |
SocketException | The remote address is unknown, invalid, or unable to be resolved. |
Use this method to asynchronously trace a route to the host specified by remoteHost. After calling this method, the Hop event is raised upon each hop. Check the event for information about the hop, such as the remote address of the particular host for this hop. Upon completion of this method, the EndSend event is raised. A TraceResult object containing information about the trace operation in general, such as a collection representing all hops, is made accessible in this event.
The following example demonstrates an asynchronous trace route operation.
[Visual Basic]
Private Sub TraceTest()
' Set all hops and echoes to be synchronous
Trace1.HopType = HopType.SynchHops
' Do not exceed 25 hops
Trace1.MaxHops = 25
' Begin the trace route operation.
Trace1.BeginSend("www.dart.com", Nothing)
End Sub
Private Sub Trace1_Hop(ByVal sender As Object, ByVal e As HopEventArgs) Handles Trace1.Hop
' Display information about the hop
Debug.WriteLine("Time-to-live for the hop: " & e.Result.TTL)
Debug.WriteLine("Remote address: " & e.Result.RemoteAddress)
' Now display info about each of the three echoes
Debug.WriteLine("Response times for this hop")
Dim er As EchoResult
For Each er In e.Result.Echoes
Debug.WriteLine(er.ResponseTime)
Next
Debug.WriteLine("Average time for this hop: " & e.Result.AverageTime)
End Sub
Private Sub Trace1_EndSend(ByVal sender As Object, ByVal e As TraceEventArgs) Handles Trace1.EndSend
' Check for any exceptions
If e.Exception Is Nothing Then
' Trace operation is complete, display info.
Debug.WriteLine("Total hops: " & e.Result.Hops.Length)
Else
Debug.WriteLine("Exception: " & e.Exception.Message)
End If
End Sub
[C#]
private void TraceTest()
{
// Set all hops and echoes to be synchronous
trace1.HopType = HopType.SynchHops;
// Do not exceed 25 hops
trace1.MaxHops = 25;
// Begin the trace route operation.
Trace1.BeginSend("www.dart.com", null);
}
private void trace1_Hop(object sender, HopEventArgs e)
{
// Display information about the hop
Debug.WriteLine("Time-to-live for the hop: " +
e.Result.TTL);
Debug.WriteLine("Remote address: " + e.Result.RemoteAddress);
// Now display info about each of the three echoes
Debug.WriteLine("Response times for this hop");
foreach(EchoResult er in e.Result.Echoes)
Debug.WriteLine(er.ResponseTime);
Debug.WriteLine("Average time for this hop: " + e.Result.AverageTime);
}
private void trace1_EndSend(object
sender, TraceEventArgs e)
{
// Check for any exceptions
if(e.Exception == null)
// Trace operation completed successfully, display info.
Debug.WriteLine("Total hops: " +
e.Result.Hops.Length);
else
Debug.WriteLine("Exception: " +
e.Exception.Message);
}
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Trace Class | Trace Members | Overload List
Send comments on this topic.
Documentation version 1.1.2.0.
© 2008 Dart Communications. All rights reserved.